package me.zhengjie.modules.quartz.task;

import lombok.extern.slf4j.Slf4j;
import me.zhengjie.business.domain.Zhsq;
import me.zhengjie.business.domain.vo.PersonVo;
import me.zhengjie.business.repository.ZhsqRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Component;

import javax.transaction.Transactional;
import java.util.List;

/**
 * 查询参保类型为空，并改成对应的结果
 * @author xiahongbo
 * @date 2023-10-19
 */
@Slf4j
@Async
@Component
public class YbkhTask {

    @Autowired
    private ZhsqRepository zhsqRepository;

    @Transactional
    public void ybkh() {
        // 当前时间
        List<Zhsq> list = zhsqRepository.selectYbkh();
        for (int i = 0; i < list.size(); i++) {
            Zhsq zhsq = list.get(i);
            PersonVo personVo = zhsqRepository.selectByAac001(zhsq.getBisZhsqGrbh());
            if(personVo != null) {
                zhsqRepository.updateYbkh(personVo.getCardno(), zhsq.getBisZhsqId());
            }
        }
    }
}
